<template>
  <div>
    <!--面包屑导航-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>管理员界面</el-breadcrumb-item>
      <el-breadcrumb-item>商品仓库</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <!--搜索区域-->
      <el-row :gutter="20">
      </el-row>

      <el-table :data="waredata" border stripe class="table-box1">
        <el-table-column type="index"></el-table-column>
        <el-table-column label="商品分类编号" prop="Icode"></el-table-column>
        <el-table-column label="工厂代码" prop="Fcode"></el-table-column>
        <el-table-column label="商品说明" prop="Iexplain"></el-table-column>
        <el-table-column label="商品价格" prop="Iprice"></el-table-column>
        <el-table-column label="商品库存" prop="Iamount"></el-table-column>
        <el-table-column label="商品重量" prop="Iweight"></el-table-column>
        <el-table-column label="操作" prop="">
          <template>
            <el-tooltip effect="dark" content="修改" placement="top">
              <el-button
                type="primary"
                icon="el-icon-edit"
                size="mini"
                @click="showmod"
              ></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    


    <el-dialog
      title="修改订单细则"
      :visible.sync="editDialogVisible"
      width="50%"
      @close="Eclose"
    >
      <!--内容主体区域-->
      <el-form
        :model="editForm"
        :rules="editFormrules"
        ref="editFormRef"
        label-width="200px"
      >
        <el-form-item label="要修改的商品分类编号" prop="Ucode">
          <el-input v-model="editForm.Ucode"></el-input>
        </el-form-item>
        <el-form-item label="输入工厂代码" prop="Ufcode">
          <el-input v-model="editForm.Ufcode"></el-input>
        </el-form-item>
        <el-form-item label="输入商品说明" prop="Uiexplain">
          <el-input v-model="editForm.Uiexplain"></el-input>
        </el-form-item>
        <el-form-item label="输入商品价格" prop="Uiprice">
          <el-input v-model="editForm.Uiprice"></el-input>
        </el-form-item>
        <el-form-item label="输入商品库存" prop="Uiamount">
          <el-input v-model="editForm.Uiamount"></el-input>
        </el-form-item>
        <el-form-item label="输入商品重量" prop="Uiweight">
          <el-input v-model="editForm.Uiweight"></el-input>
        </el-form-item>
      </el-form>
      <!--底部区域-->
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="editorder">确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      query: "",
      waredata: [],
      //修改框显示
      editDialogVisible: false,

      //修改所需属性
      editForm: {
        Ucode: "",
        Ufcode: "",
        Uiexplain: "",
        Uiprice: "",
        Uiamount: "",
        Uiweight: "",
      },

      editFormrules: {
        Ucode: [
          {
            required: true,
            message: "请输入商品分类编号",
            trigger: "blur",
          },
        ],
        Ufcode: [
          {
            required: true,
            message: "请输入工厂代码",
            trigger: "blur",
          },
        ],
        Uiexplain: [
          {
            required: true,
            message: "请输入商品说明",
            trigger: "blur",
          },
        ],
      },

    };
  },
  created() {
    this.geto_messagedata();
  },
  methods: {
    async geto_messagedata() {
      const { data: res } = await this.$http.post("Data/apis/iventoryget", {
        params: this.query,
      });
      this.waredata = res;
      console.log(res);
    },

    showmod() {
      this.editDialogVisible = true;
    },

    Eclose() {
      this.$refs.editFormRef.resetFields();
    },

    editorder() {
      this.$refs.editFormRef.validate(async (valid) => {
        if (!valid) return;

        const { data: psn } = await this.$http.post(
          "Data/apis/iventoryput",
          this.editForm
        );

        if (psn.code == 200) {
          this.$message.success("修改成功");
          this.editDialogVisible = false;
          this.geto_messagedata();
        }
      });
    },

  },
};
</script>

<style>
.table-box1 {
  margin-top: 15px;
  font-size: 12px;
}
</style>